
tempfile main
foreach y of numlist 2007(1)2008 {
	global y `y'
	use ape* siren s_brut using "${tmp}\dads${y}", clear
	gduplicates drop
	drop if substr(siren,1,1) == "P"
	drop if mi(apen)
	gen year = ${y}
	cap append using `main'
	save `main', replace
	}
gduplicates drop
bys siren: egen naf_rev1 = mode(apen) if strlen(apen) == 4, minmode
bys siren: egen naf_rev2 = mode(apen) if strlen(apen) == 5, minmode
bys siren (naf_rev1): replace naf_rev1 = naf_rev1[_N]
bys siren (naf_rev2): replace naf_rev2 = naf_rev2[_N]
bys naf_rev1 : egen tot_sal_rev1 = sum(s_brut)
bys naf_rev1 naf_rev2: egen tot_sal_rev1rev2 = sum(s_brut)
keep siren naf_rev? tot_sal*
gduplicates drop
gen share = tot_sal_rev1rev2 / tot_sal_rev1
drop tot_sal*
compress
save "${data}/Utils/Siren_NAF_rev12_dads", replace